package org.example.modules.user.controller;

import com.alibaba.fastjson2.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.example.modules.user.common.Commsult;
import org.example.modules.user.entry.ApplyDetails;
import org.example.modules.user.entry.vo.ApplyRecordsVo;
import org.example.modules.user.service.ApplyDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description ApplyDetailsController
 * @Author xiaotian
 * @Date 2025-04-15
 */
@RestController
@RequestMapping("/wxApi/details")
@Slf4j
public class ApplyDetailsController {
    @Autowired
    private ApplyDetailsService applyDetailsService;

    @PostMapping
    public Commsult addApplyDetails(@RequestBody JSONObject data){
        applyDetailsService.addApplyDetails(data);
        return Commsult.success(null);
    }

    @GetMapping("/apply")
    public Commsult<List<ApplyDetails>> getApply(){
        return Commsult.success(applyDetailsService.getApply());
    }

    @PostMapping("/updateStatus")
    public Commsult updateApplyStatus(@RequestBody JSONObject data){
        applyDetailsService.updateApplyStatus(data);
        return Commsult.success(null);
    }

    @PostMapping("/getApplyList")
    public Commsult<List<ApplyRecordsVo>> getApplyRecords(@RequestBody JSONObject data){

        return Commsult.success(applyDetailsService.getApplyRecords(data));
    }

    @PostMapping("/getApplyDetails")
    public Commsult<ApplyDetails> getApplyDetails(@RequestBody JSONObject data){

        return Commsult.success(applyDetailsService.getApplyDetails(data));
    }
}
